package com.woniu.controller;

import cn.hutool.core.io.FileUtil;
import com.woniu.utils.ResponseResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
@CrossOrigin
public class FileController {

    @PostMapping("/upload")
    public ResponseResult upload(MultipartFile file) {
        System.out.println(file.getOriginalFilename());
        FileUtil.mainName(file.getOriginalFilename());
        System.out.println(file.getSize());
        return ResponseResult.success("文件上传成功");
    }
}
